<!-- START OF FUNCTIONS -->
<script type="text/javascript">
	<?php
	// Copy a php array into a javascript array.
	$array_JS="usrList";

	printf("%s = new Array();\n",$array_JS);

	for($i=0; $i < sizeof($clientUsr); $i++)
	{
		printf("%s[%s]= new Array();\n",$array_JS, $i);

				foreach($clientUsr[$i]['User'] as $key => $value)
				{
					if ($key == 'id' || $key == 'firstname' || $key == 'lastname' || $key == 'company_id'){
						printf("%s[%s].%s =%s;\n",$array_JS, $i, $key,
							is_string($value) ?  "\"".addslashes($value)."\"" : $value);
					}
				}
	}
	
	// Copy a php array into a javascript array.
	$array_JS="contractList";

	printf("%s = new Array();\n",$array_JS);

	for($i=0; $i < sizeof($contracts); $i++)
	{
		printf("%s[%s]= new Array();\n",$array_JS, $i);

				foreach($contracts[$i]['Contract'] as $key => $value)
				{
					printf("%s[%s].%s =%s;\n",$array_JS, $i, $key,
						is_string($value) ?  "\"".addslashes($value)."\"" : $value);
				}
	}
	?>
</script>

<?php echo $javascript->link('project_scripts.js');?>

<!-- END OF FUNCTIONS -->


<div class="layoutProject">
	<div class="addProject">
		<?php echo $form->create('Project', array('action' => 'add')); ?>
			<h2><?php echo __('project'); ?></h2>
			<?php echo __('project').$form->input('name', array('label' => false)); ?>
            
			<?php echo __('contract_choice').$form->select('contract_id', $format->buildContractArr($contracts), null, array('onChange'=>'javascript:update_client_list(this.options[this.options.selectedIndex].value)', 'error'=>'Please select a Contract.')); echo $html->link(__('create_contract', true), "/contracts/add/");
			echo $form->error('contract_id', 'Please select a Contract.'); ?>
            
            <?php echo "<br />Description<br />".$form->textarea('description'); ?>

			<div id="gescom">
			<?php echo $ajax->link(__('link_to_gescom', true), '/gescom/add', array('update'=>'gescom')); ?>
			</div>
			
			<h2>Smile</h2>
			<?php echo __('project_director').$form->select('smileDP.id', $format->buildUsrArr($smileUsr), null, array('id'=>'smileDP'/*, 'onChange'=>'javascript:update_list(this.id, this.options[this.options.selectedIndex])'*/)); //echo $html->link(__('create_new_project_director'), "/users/adduser/"); ?>
			<br />
			<?php echo __('team_leader').$form->select('smileCP.id', $format->buildUsrArr($smileUsr), null, array('id'=>'smileCP'/*, 'onChange'=>'javascript:update_list(this.id, this.options[this.options.selectedIndex])'*/)); //echo $html->link(__('create_new_team_leader'), "/users/adduser/"); ?>
			
			<div class="users_selection_layout">
				<table border=0>
					<tr>
						<td>
							<?php echo $form->select('Smile_Left_List', $format->buildUsrArr($smileUsr), null, array('id' => 'SmileLeft', 'multiple' => 'multiple', 'size' => '10', 'style'=>'width:150px;'), False); ?>
						</td>
						<td>
							<input id="l2r_smile" name="left2right" type="button" value=">" onClick="javascript:switch_list('SmileLeft', 'SmileRight')">
							<br />
							<input id="r2l_smile" name="left2right" type="button" value="<" onClick="javascript:switch_list('SmileRight', 'SmileLeft')">
						</td>
						<td>
							<?php echo $form->select('smileDev.id', array(), null, array('id' => 'SmileRight', 'multiple' => 'multiple', 'size' => '10', 'style'=>'width:150px;'), False); ?>
                            
						</td>
					</tr>
				</table>	
			</div>
			
			<h2>Client</h2>
			<?php echo __('team_leader').$form->select('clientCP.id', array(), null, array('id' => 'ClientCP'/*, 'onChange'=>'javascript:update_list(this.id, this.options[this.options.selectedIndex])'*/)); //echo $html->link(__('create_new_team_leader'), "/users/adduser/"); ?>
			
			<div class="users_selection_layout">
				<table border=0>
					<tr>
						<td>
							<?php echo $form->select('Client_Left_List', array(), null, array('id' => 'ClientLeft', 'multiple' => 'multiple', 'size' => '10', 'style'=>'width:150px;'), False); ?>
						</td>
						<td>
							<input id="l2r_smile" name="left2right" type="button" value=">" onClick="javascript:switch_list('ClientLeft', 'ClientRight')">
							<br />
							<input id="r2l_smile" name="left2right" type="button" value="<" onClick="javascript:switch_list('ClientRight', 'ClientLeft')">
						</td>
						<td>
							<?php echo $form->select('clientDev.id', array(), null, array('id' => 'ClientRight', 'multiple' => 'multiple', 'size' => '10', 'style'=>'width:150px;'), False); ?>
						</td>
					</tr>
				</table>
			</div>
			
			<?php echo $form->submit(__('validate', true)); ?>
		<?php echo $form->end(); ?>
	</div>
</div>